package thread;


public class Demo5 {
    public  static final long  count = 100_0000_0000l;
    public static void fun1(){
        long beg = System.currentTimeMillis();
        long a = 0;
        long b = 0;
        for (long i = 0; i < count; i++) {
            a++;
        }
        for (long j = 0; j < count; j++) {
            b++;
        }
        long end = System.currentTimeMillis();
        System.out.println("消耗时间"+ (end-beg)+"ms");
    }
    public static void fun2() throws InterruptedException {
        long beg = System.currentTimeMillis();
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                long a = 0;
                for (long i = 0; i < count; i++) {
                    a++;
                }
            }
        });
        t.start();
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                long b = 0;
                for (long i = 0; i < count; i++) {
                    b++;
                }
            }
        });
        t1.start();
        t.join();
        t1.join();
        long end = System.currentTimeMillis();
        System.out.println("消耗时间"+(end-beg)+"ms");
    }
    public static void main(String[] args) throws InterruptedException {
        fun1();
        //fun2();
    }
}
